/**
 * @api {get} /api/public/v1/suggestions/browse 建议列表
 */
exports.browse = function ({query}, {models: {Suggestions}, controller}) {
    return Suggestions.findAndCountAll(controller.pagination({
        params: query,
        filters: ['type', 'user_id', 'feature', 'status'],
        likes: ['content'],
        attributes: ['id', 'type', 'content', 'images', 'feature', 'status']
    }));
}

/**
 * @api {get} /api/public/v1/suggestions/load 加载建议
 */
exports.load = function ({query}, {models: {Suggestions}}) {
    return Suggestions.findOne({
        where: {id: query.id},
        attributes: ['id', 'type', 'content', 'images', 'feature', 'status']
    });
}

/**
 * @api {post} /api/public/v1/suggestions/add 添加建议
 */
exports.add = function ({body, user_id}, {models: {Suggestions}}) {
    body.user_id = user_id;
    return Suggestions.create(body).then(function (data) {
        return {success: true, data: data};
    });
}